﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_teams : System.Web.UI.Page
{
    protected Administrator admin;
    protected int SortID;
    protected void Page_Load(object sender, EventArgs e)
    {
        admin = Administrator.Check();
        if (admin == null)
        {
            Session.Add(Params.SystemError, "请先登录");
            Response.Redirect(Params.RootHttp + "default.aspx");
        }
        if (!Page.IsPostBack)
        {
            this.MyDataBind();
        }
    }

    public void MyDataBind()
    {
        this.conNav.Title = "团队列表";
        this.SortID = 1;
        this.repTeam.DataSource = Team.TeamsDt();
        this.repTeam.DataBind();
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string tn = this.tbName.Text.Trim();
        string y = this.tbYjfx.Text.Trim();
        string email = this.tbEmail.Text.Trim();
        string uid = this.tbID.Text.Trim();
        if (tn == "" || y == ""||uid=="")
        {
            this.info.SetMessage("ID，团队名称和研究方向不能为空");
            return;
        }
        string tip = "";
        int g = Team.Add(uid, tn, email, y, ref tip);
        if (g == 0)
        {
            Session.Add(Params.SystemError, tip);
            Response.Redirect(Request.RawUrl);
        }
        Session.Add(Params.SystemError, "添加成功！");
        Response.Redirect(Params.AdminFolderHttp + "teams.aspx?guid=" + g.ToString());
    }
}
